package db

import (
	"appshop/conf"
	"fmt"
	"github.com/jmoiron/sqlx"
)

var (
	Db *sqlx.DB
)

func InitDb() {
	dsn := conf.Config.Database.Source
	db, err := sqlx.Open("mysql", dsn)
	if err != nil {
		panic(err)
		// fmt.Println("open mysql failed, ", err)
		// return
	}
	fmt.Println("数据库连接成功...")
	db.SetMaxOpenConns(20)
	db.SetMaxIdleConns(10)
	Db = db
}
